import defaltImg from '@/assets/images/200.png'
// import {useObserver}  from  '@/compositions'
import { useIntersectionObserver } from '@vueuse/core'
export default {
  install(Vue){
    Vue.directive('lazyImg',{
      mounted(el,binding){
        console.log(el,99);
        //  图片懒加载
        // const target=useObserver(getHotList)
        const { stop } = useIntersectionObserver(
          // 监听目标元素
          el,
          ([{ isIntersecting }], observerElement) => {
            if (isIntersecting) {
              el.onerror=function(){
                //  图片加载失败显示默认图片
                el.src=defaltImg
              }
              //  这里显示传过来的图片数据
              console.log(binding,9);
              el.src=binding.value
            }
          }
        )
      }
    })
  }
}